package com.sise.parkinglot.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sise.parkinglot.entity.Park;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author ZJ
 */
public interface ParkMapper extends BaseMapper<Park> {

    /**
     * @param day 前day天
     * @return 根据车型获取前day天数据数
     */
    @Select("select count(1) from park where station_type = #{station_type} and TO_DAYS(NOW()) - TO_DAYS(start_park) = #{day}")
    int getOneDayByStationType(int station_type, int day);

    /**
     * @param day 前day天
     * @return 获取前day天数据
     */
    @Select("select * from park where TO_DAYS(NOW()) - TO_DAYS(start_park) = #{day}")
    List<Park> getOneDay(int day);

    /**
     * @param day 前day天
     * @return 获取前day天结束时数据
     */
    @Select("select * from park where TO_DAYS(NOW()) - TO_DAYS(end_park) = #{day}")
    List<Park> getOneEndDay(int day);
}
